import 'dotenv/config'
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { LogMiddleware } from './middlewares/log.middleware'
import { TransformInterceptor } from 'src/interceptors/transform.interceptor'
// import {AuthGuard} from './guard/auth.guard'
// import {ValidationPipe} from '@nestjs/common'
import { HttpExceptionFilter } from 'src/filters/http-exception.filter'

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  //全局中间件
  app.use(new LogMiddleware().use)
  //全局守卫
  // app.useGlobalGuards(new AuthGuard())
  //全局管道
  // app.useGlobalPipes(new ValidationPipe())
  //全局拦截器
  app.useGlobalInterceptors(new TransformInterceptor())
  //全局过滤器
  app.useGlobalFilters(new HttpExceptionFilter())

  await app.listen(3000);
}
bootstrap();
